import {post} from '../../../utils/axios'

const state = {
  name: '发布情况',
  active: null,
  text: '1',
  count: '',
  info: [],
  show: true,
  interval: ''
}

const mutations = {
  loadPublishInfo (state, payload) {
    let url = '/publisher/publish_info/'
    post(url, {
      opt: payload
    }).then((response) => {
      state.info = JSON.parse(response).info
      state.count = response.count
    }).catch((error) => {
      alert(error.response.data)
    })
  },
  closePublishInfo (state) {
    this._vm.$data.$$state.listPublish.pubInfoDialog = false
  }
}

const actions = {
  closePublishInfo ({commit}) {
    commit('closePublishInfo')
  },
  loadPublishInfo ({commit}, payload) {
    state.interval = setInterval(() => {
      commit('loadPublishInfo', payload)
    }, 2000)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
